#include "stdafx.h"
#include "../../NSNetLibSrc/Framework/ServerFramework/ServerFramework.h"
#include "../../NSNetLibSrc/Framework/ServerFramework/ServerProcessMain.h"
#include "../../NSNetLibSrc/Include/NetFramework_MsgDef.h"

class CFarmManagerMainProcess : public CServerProcessMain
{
public:
	BS_DECLARE_DYNCREATE( CFarmManagerMainProcess);

protected:
	void	AssignMessageMap();
}; 

BS_IMPLEMENT_DYNCREATE( CFarmManagerMainProcess, CServerProcessMain);


class CFarmManager : public CServerApp
{
	bool InitializeLocalData()
	{
		SetExecutionStep( eSES_Operating);
		return true;
	}

	bool InitializeServerTask_Main()
	{
		SetDebugHelperHandlers();

		if( !g_pNetEngine->RegisterTask( SFTASK_PROCESSMAIN, NULL, BS_RUNTIME_CLASS( CFarmManagerMainProcess), NULL))
			return false;
		if( !g_pNetEngine->ActivateService( SFTASK_PROCESSMAIN, 1, THREAD_PRIORITY_NORMAL, 0, 0, NULL))
			return false;

		return true;	
	}

	virtual void SetupNetEngineConfig();
};

void CFarmManager::SetupNetEngineConfig()
{
	CServerApp::SetupNetEngineConfig();
	
#ifdef APPLY_SECURED_KEY_EXCHANGE
	m_NetEngineConfig.SecurityMode = BSNET_DEFAULT | BSNET_DIFFIEHELLMAN_DEEPDARK;
#endif

}


CFarmManager g_FarmManager;

IMPLEMENT_WINMAIN( ServerFramework::eMT_Window, L"FarmManager", &g_FarmManager)

void CFarmManagerMainProcess::AssignMessageMap()
{
	CServerProcessMain::AssignMessageMap();
}
